// SPDX-License-Identifier: GPL-2.0
/*
 * CPP: CLASS DERIVED
 *
 * (C) 2024.05.23 BiscuitOS <buddy.zhang@aliyun.com>
 */
#include <iostream>
#include <string.h>

/* BASIC CLASS */
class PERSON {
public:
	/* ATTRIBUTE */
	std::string name;
	int age;

	/* CONSTRUCTOR */
	PERSON(std::string n, int a) : name(n), age(a) {}

	/* METHOD */
	virtual void show() {
		std::cout << "BASIC CLASS" << std::endl;
	} 
};

/* DERIVED CLASS */
class STUDENT : public PERSON {
public:
	/* ATTRIBUTE */
	std::string school;

	/* CONSTRUCTOR */
	STUDENT(std::string n, int a, std::string sc) : PERSON(n, a), school(sc) {}

	/* METHOD */
	void show() override {
		std::cout << "DERIVED CLASS" << std::endl;
	}
};

int main(void)
{
	/* CREATE INHERITANCE OBJECT */
	STUDENT std = STUDENT("BiscuitOS", 8, "GITHUB");
	STUDENT *st = new STUDENT("BOS", 8, "GITHUB");
	/* CREATE DERIVED CLASS */
	PERSON *pn = new STUDENT("BRIOLER", 3, "GITEE");
	PERSON pm  = STUDENT("Linux", 6, "KERNEL"); 

	/* INVOKE INHERITANCE METHOD */
	std.show();
	/* INVOKE INHERITANCE METHOD */
	st->show();
	/* INVOKE DERIVED METHOD */
	pn->show();
	/* INVOKE BASIC METHOD */
	pm.show();

	return 0;
}
